package stringdemo;

public class StringDemo10Replace {
    public static void main(String[] args) {
        //1.获取说的话
        String talk = "TMD,你说个屁,你个SB";
        //2.定义一个敏感词库
        String[] arr = {"TMD","CNM","SB","MLGB"};
        //2.把里面的敏感词TMD替换为***
//        talk = talk.replace("TMD","***");
//        System.out.println(talk);

        //3.循环得到数组中的每一个敏感词，依次进行替换
        for (int i = 0; i < arr.length; i++) {
            talk = talk.replace(arr[i],"***");
        }

        //4.打印
        System.out.println(talk);

    }
}
